<?
$title = "Welcome";

require_once("required/external_module.php");


if (empty($title)) {
    $title = "Welcome";
}
if (empty($_SESSION['pid'])) {
    $_SESSION['pid'] = 1;
}

//set_error_handler("errRedirect",E_ALL);
$include_extra = "";
$loginmsg = "";
$mainpage = "<a href='index.php'>Home</a>";


if (isset($_POST['login_email']) && isset($_POST['login_password'])) {
    $email = $_POST['login_email'];
    $password = $_POST['login_password'];
    $chklogin = mysql_query("select * from os_member where email='$email' and password='$password'");
    //$cururl=$_POST['cururl'];


    if (mysql_num_rows($chklogin) > 0) {
        /*
          if(mysql_result($chklogin,0,'status')!='activated')
          {
          $pos = strpos($_SESSION['fullurl'], '?');
          if ($pos == true)
          {
          $_SESSION['fullurl'].="&errormsg=2&username=$loginname";
          }
          else
          {
          $_SESSION['fullurl'].="?errormsg=2&username=$loginname";
          }
          header("Location:".$_SESSION['fullurl']);
          }
          else
          {
         */
        $_SESSION['email'] = mysql_result($chklogin, 0, 'email');
        $_SESSION['loginname'] = mysql_result($chklogin, 0, 'name');
        $_SESSION['member_status'] = mysql_result($chklogin, 0, 'status');
        $_SESSION['member_type'] = mysql_result($chklogin, 0, 'member_type');
        $_SESSION['loginid'] = mysql_result($chklogin, 0, 'id');
        $_SESSION['member_email'] = mysql_result($chklogin, 0, 'email');
        $update = mysql_query("update os_member set total_login=total_login+1 where id=" . mysql_result($chklogin, 0, 'id'));

        if (empty($_POST['fromBill'])) {
            ?>
            <script language="javascript">
                window.location="index.php";
            </script>
            <?
        } else {
            ?>
            <script language="javascript">
                window.location="os_bill.php";
            </script>
            <?
        }
    } elseif (mysql_num_rows($chklogin) == 0) {
        if (empty($_POST['fromBill'])) {
            ?>
            <script language="javascript">
                window.location="os_login.php?errormsg=1";
            </script>
            <?
        } else {
            ?>
            <script language="javascript">
                window.location="os_bill.php?errormsg=1";
            </script>
            <?
        }
    } else {
        echo "unknown error!!";
    }
}

if (empty($_SESSION['loginid'])) {
    $member_id = 0;
} else {
    $member_id = $_SESSION['loginid'];
    $update_status = mysql_query("update os_member set last_online=now() where id=" . $_SESSION['loginid']) or die(mysql_error());
}

if (empty($_SESSION['cart'])) {
    $header_total_items = 0;
    $header_total_amount = 0;
} else {
    $header_total_amount = $_SESSION['total_overall_price'];
    $header_total_items = $_SESSION['total_items'];
}

if (isset($_POST['changeCurrency'])) {
    $id = $_POST['changeCurrency'];
    $get_maincurrency = mysql_query("select * from os_currency where id=$id");
    $_SESSION['currency_code'] = mysql_result($get_maincurrency, 0, "currency_code");
    $_SESSION['currency_rate'] = mysql_result($get_maincurrency, 0, "rate");
    $_SESSION['currency_id'] = mysql_result($get_maincurrency, 0, "id");
    header("Location:index.php");
}

if (empty($_SESSION['currency_id'])) {
    $get_maincurrency = mysql_query("select * from os_currency where is_main=1");
    $_SESSION['currency_code'] = mysql_result($get_maincurrency, 0, "currency_code");
    $_SESSION['currency_rate'] = mysql_result($get_maincurrency, 0, "rate");
    $_SESSION['currency_id'] = mysql_result($get_maincurrency, 0, "id");
}
?>

<html>
    <head>
        <title><?= $title ?> - Ceriatone</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <?
        if (!empty($share_title)) {
            ?>
            <meta property="og:title" content="<?= $share_title ?>" />
            <meta property="og:type" content="product" />

            <meta property="og:image" content="<?= $share_piclink ?>" />
            <meta property="og:site_name" content="Ceriatone" />

            <?
        }
        ?>
        <link rel="shortcut icon" href="images/favicon.ico">
        <link href="required/style.css" rel="stylesheet" type="text/css">
        <script src="required/js/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script src="required/js/common_javascript.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="required//colorbox.css">
        <script type="text/javascript" src="required/js/jquery.colorbox-min.js"></script>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">


    <center>
        <table width="100%" height="100%" cellpadding="0" cellspacing="0">
            <tr>
                <Td width="100%" valign="top">
                    <br>
                    <!-- ------------------------ Top Title Start ------------------------------- -->
                    <table align="center" id="Table_01" style="padding-right:40px;" width="1201"  border="0" cellpadding="0" cellspacing="0">

                        <tr>
                            <td rowspan="2">
                                <img src="images/header_02.png" width="322" height="170" alt=""></td>
                            <td>
                                <a href="index.php"><img src="images/header_03.png" width="611" height="144" border="0"  alt=""></a></td>
                            <td rowspan="2">
                                <img src="images/header_04.png" width="268" height="170" alt=""></td>
                        </tr>
                        <tr>
                            <td>
                                <img src="images/header_05.png" width="611" height="26" alt=""></td>
                        </tr>
                    </table>
                </Td>
            </tr>
            <!-- ------------------------ Top Title End --------------------------------- -->



            <!-- ------------------------ Top Menu Start -------------------------------- -->
            <?
            $home_menu = "out";
            $amps_menu = "out";
            $other_products_menu = "out";
            $dealers_menu = "out";
            $info_menu = "out";
            $news_menu = "out";


            switch ($_SESSION['pid']) {
                case "home":
                    $home_menu = "over";
                    break;
                case "AMPS":
                    $amps_menu = "over";
                    break;
                case "OTHER PRODUCTS":
                    $other_products_menu = "over";
                    break;
                case "dealers":
                    $dealers_menu = "over";
                    break;
                case "info":
                    $info_menu = "over";
                    break;

                case "news":
                    $news_menu = "over";
                    break;
                    break;



                default:

                    $home_menu = "out";
                    $amps_menu = "out";
                    $other_products_menu = "out";
                    $dealers_menu = "out";
                    $info_menu = "out";
                    $news_menu = "out";


                    break;
            }
            ?>

            <tr>
                <Td width="100%" valign="top">
                    <table align="center" id="Table_01" width="1200" height="42" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <img src="images/menu_01.png" width="331" height="42" alt=""></td>
                            <td>
                                <a href="index.php"><img src="images/home_<?= $home_menu ?>.png" border="0" onMouseOver="this.src='images/home_over.png'" onMouseOut="this.src='images/home_<?= $home_menu ?>.png'"  width="73" height="42" alt=""></a></td>
                            <td>
                                <a href="os_products.php?pid=1"><img src="images/amps_<?= $amps_menu ?>.png"  border="0"  onMouseOver="this.src='images/amps_over.png'"  onMouseOut="this.src='images/amps_<?= $amps_menu ?>.png'" width="69" height="42" alt=""></a></td>
                            <td>
                                <a href="os_products.php?pid=2"><img src="images/other_products_<?= $other_products_menu ?>.png"   border="0" onMouseOver="this.src='images/other_products_over.png'" onMouseOut="this.src='images/other_products_<?= $other_products_menu ?>.png'" width="134" height="42" alt=""></a></td>
                            <td>
                                <a href="os_content.php?type=dealers"><img src="images/dealers_techies_<?= $dealers_menu ?>.png" border="0"   onMouseOver="this.src='images/dealers_techies_over.png'"  onMouseOut="this.src='images/dealers_techies_<?= $dealers_menu ?>.png'" width="146" height="42" alt=""></a></td>
                            <td>
                                <a href="os_content.php?type=info"><img src="images/info_<?= $info_menu ?>.png" border="0"  onMouseOver="this.src='images/info_over.png'"  onMouseOut="this.src='images/info_<?= $info_menu ?>.png'" width="62" height="42" alt=""></a></td>
                            <td>
                                <a href="os_announcement_view_all.php"><img src="images/news_<?= $news_menu ?>.png" border="0" onMouseOver="this.src='images/news_over.png'"  onMouseOut="this.src='images/news_<?= $news_menu ?>.png'" width="67" height="42" alt=""></a></td>
                            <td>
                                <img src="images/menu_08.png" width="318" height="42" alt=""></td>
                        </tr>
                    </table>
                </Td>
            </tr>
            <!-- ------------------------ Top Menu End ------------------------------- -->


            <tr>
                <Td width="100%" valign="top" >
                    <table width="1200" height="30" bgcolor="#1c1c1c" align="center">
                        <tr>
                            <Td style="padding-left:30px;padding-right:30px"  >
                                <?
                                if (empty($_SESSION['loginid'])) {
                                    ?>  

                                    <script language="javascript">
                                        function removeText()
                                        {
                                            if(document.loginfrm.login_email.value=="Email")
                                            {
                                                document.loginfrm.login_email.value="";
                                            }
            						  
                                            if(document.loginfrm.login_password.value=="password")
                                            {
                                                document.loginfrm.login_password.value="";
                                            }
                                        }
            				  
            				  
                                    </script>

                                    <table>
                                        <form action="os_login.php" method="post" name="loginfrm">
                                            <tr>
                                                <Td>
                                                    <input type="text" size="30" name="login_email" value="Email" style="border: 0px solid #000000;" onFocus="removeText()">
                                                </Td>
                                                <Td>
                                                    <input type="password" size="30" name="login_password" value="password" style="border: 0px solid #000000;"  onFocus="removeText()">
                                                </Td>
                                                <Td>
                                                    <input type="submit" value="Login" class="button white small">
                                                    <input type="button" value="Register" class="button white small" onclick="window.open('os_register.php','_self')">
                                                </Td>
                                            </tr>
                                        </form>
                                    </table>

                                    <?
                                } else {
                                    ?>


                                    <table>
                                        <td><font  class="title_side">Welcome, <?= $_SESSION['loginname'] ?></font></td>

                                        <td>
                                            <table>
                                                <Td width="34"><a href='os_viewdetails.php'><img src="images/icons/btn_myprofile.png" border="0" /></a></Td>
                                                <Td width="34"><a href='os_myfav.php'><img src="images/icons/btn_wishlist.png" border="0" /></a></td> 
                                                <Td width="34"><a href='os_mybill.php'><img src="images/icons/btn_order.png" border="0" /></a></Td>
                                                <Td width="34"><a href='os_myhistory.php'><img src="images/icons/btn_shophistory.png" border="0" /></a></Td>
                                                <Td width="34"><a href='logout.php'><img src="images/icons/btn_logout.png" border="0" /></a></td>
                                            </table>         
                                        </Td>

                                    </table>
                                <? } ?>         
                            </td>
                            <Td valign="middle" style="padding-right:30px">
                                <form action="os_search.php" method="post" name="searchfrm">	
                                    <table align="right" cellpadding="0" cellspacing="0" >
                                        <Td>
                                            <script language="javascript">
        
                                                function showUpdate()
                                                {
                                                    changeContent("required/js/ajax_update_cart_info.php","divCartInfo");
                                                    var o=document.getElementById("divCartUpdate");
                                                    var r=o.style;
                                                    r.position='absolute';			
                                                    $('#divCartUpdate').slideDown('slow', function() {
                                                        setTimeout(function(){
                                                            $('#divCartUpdate').slideUp('slow',function(){});
                                                        },3000)
                                                    });
                            
                                                }
                            
                            
                                
                                                function doUpdate()
                                                {
                                                    var pid=document.getElementById("pid").value;
                                                    var item=document.getElementById("item").value;
                                                    var quantity=document.getElementById("quantity").value;
                                                    changeContent("required/js/ajax_update_cart.php?pid="+pid+"&item="+item+"&quantity="+quantity,"divCartUpdate");
                                                    setTimeout("showUpdate()",1000);
                                                }
                            
                            
                                                function showUpdateOnScreen()
                                                {
                                                    changeContent("required/js/ajax_update_cart_info.php","divCartInfo");
                            
                                                }
                            
                                                function doUpdateOnScreen(id)
                                                {
                                                    var pid=document.getElementById("pid").value;
                                
                                                    var item=document.getElementById("item").value;
                                                    var quantity=document.getElementById("quantity").value;
                                                    var addon_count=0;
                                                    var addon_param="";
								
                                                    if(document.frm.addon_id)
                                                    {
                                                        var boxes = document.frm.addon_id.length;
									 
                                                        if(boxes==undefined)boxes=1;
									  
                                                        if(boxes==1)
                                                        {
                                                            if (document.frm.addon_id.checked == true )
                                                            {
                                                                add_on_id=document.frm.addon_id.value;
												
                                                                addon_param="&addon_id[]="+add_on_id;										
												
                                                            }   
                                                        }
                                                        else
                                                        {
                                                            for (i = 0; i < boxes; i++) 
                                                            {
                                                                if (document.frm.addon_id[i].checked) 
                                                                {
                                                                    add_on_id=document.frm.addon_id[i].value;
												
                                                                    addon_param+="&addon_id[]="+add_on_id;										
                                                                }
											
                                                            }
                                                        }
								   
							  	
                                                    }
								
								
                                                    $.colorbox({height:400,width:400,href:"required/js/ajax_update_cart.php?pid="+pid+"&item="+item+"&quantity="+quantity+""+addon_param,
									
                                                        onComplete:function(){ showUpdateOnScreen();}
									
                                                    });
								
						
								
                              
                                                }
							
                                                function closeColorBox()
                                                {
                                                    $.fn.colorbox.close();
                                                }
                                            </script>
                                            <div id="divCartInfo">
                                                <a href="os_products.php"><img src="images/icons/shopping_cart.png" align="absmiddle" border="0"></a>

                                                <font class="shopping_cart_info"><?= $header_total_items ?> item(s)</font></a> <font class="shopping_cart_info">|</font>
                                                <font class="shopping_cart_info"><?= $_SESSION['currency_code'] ?> <?= number_format($header_total_amount, 2) ?> </font></a>
                                                <a href="os_mycart.php"><font class="shopping_cart_info"><u>View</u></font></a> &nbsp;
                                            </div>                      
                                        </Td>

                                        <Td style="padding-left:40px">
                                            <script language="javascript">
        
                                                function removeSearch()
                                                {
                                                    if(document.searchfrm.keyword.value=="search")
                                                    {
                                                        document.searchfrm.keyword.value="";
                                                    }
                                                }
                            
                            
                                            </script>

                                            <input type="hidden" name="sub_cat" value="">
                                            <input type="hidden" name="main_cat" value="">
                                            <input type="hidden" name="price_from" value="">
                                            <input type="hidden" name="price_to" value="">
                                            <input type="hidden" name="keyword_type" value="">
                                            <input type="text" name="keyword" id="keyword" size="25" value="search" onFocus="removeSearch()" maxlength="50" style="border: 0px solid #000000;">

                                        </Td>
                                        <Td><input type="submit" value="Go" name="btnsearch" class="button white small"></Td>

                                    </table>
                                </form>
                            </td>
                        </Tr>
                    </table>
                </td>
            </tr>

            <tr>
                <td height="100%" valign="top">
                    <table width="1200" cellpadding="0" cellspacing="0" align="center">
                        <td valign="top" >